﻿#pragma strict


var force : float;
var timeReset : float;

private var timer : float; 
private var saltado : boolean;


function Start () {

}

function Update () {

	if(saltado)
	{
		timer += Time.deltaTime;
	}
	if(timer > timeReset)
	{	
		saltado = false;
		timer = 0;
	}

}

function OnTriggerEnter(collider:Collider){
	 
	 if (collider.CompareTag("Player1"))
	 {
		if(saltado)
		{
			var characterMotor = collider.GetComponent(CharacterMotor);

			characterMotor.SetVelocity(Vector3.up*force);
			
			timer = 0;
		}
	 }
 }
 
 function OnTriggerStay(collider:Collider){
	 if(Input.GetButtonDown("Jump"))
	 {
		if (collider.CompareTag("Player1")) saltado = true;
	 }
 }